<?php

namespace common\models\user;

use Yii;

/**
 * This is the model class for table "{{%user_follower}}".
 *
 * @property int $id
 * @property string $user_id 用户UID
 * @property string $followed_user_id 被关注UID
 * @property string $remark 备注名
 * @property string $listorder
 * @property string $created_at 关注时间
 * @property int $updated_at
 */
class UserFollower extends \yii\db\ActiveRecord {

    use \common\traits\TimestampBehavior;
    use \common\traits\QueryInstanceActiveRecord;

    /**
     * @inheritdoc
     */
    public static function tableName() {
        return '{{%user_follower}}';
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            [['user_id', 'followed_user_id'], 'required'],
            [['user_id', 'followed_user_id', 'listorder', 'created_at', 'updated_at'], 'integer'],
            [['remark'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'user_id' => '用户UID',
            'followed_user_id' => '被关注UID',
            'remark' => '备注名',
            'listorder' => 'Listorder',
            'created_at' => '关注时间',
            'updated_at' => 'Updated At',
        ];
    }

    public function getFollowUser(){
        return $this->hasOne(User::className(),['id'=>'followed_user_id']);
    }

    public function getUser(){
        return $this->hasOne(User::className(),['id'=>'user_id']);
    }
}
